package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.TDSsqBet;
import com.ruoyi.business.service.ITDSsqBetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 双色球投注Controller
 * 
 * @author lx
 * @date 2022-02-28
 */
@RestController
@RequestMapping("/business/bet")
public class TDSsqBetController extends BaseController
{
    @Autowired
    private ITDSsqBetService tDSsqBetService;

    /**
     * 查询双色球投注列表
     */
    @PreAuthorize("@ss.hasPermi('business:bet:list')")
    @GetMapping("/list")
    public TableDataInfo list(TDSsqBet tDSsqBet)
    {
        startPage();
        if (tDSsqBet.getOne()!=null && tDSsqBet.getOne().length() ==1){
            tDSsqBet.setOne("0"+tDSsqBet.getOne());
        }
        if (tDSsqBet.getSeven()!=null && tDSsqBet.getSeven().length() ==1){
            tDSsqBet.setSeven("0"+tDSsqBet.getSeven());
        }
        List<TDSsqBet> list = tDSsqBetService.selectTDSsqBetList(tDSsqBet);
        return getDataTable(list);
    }

    /**
     * 导出双色球投注列表
     */
    @PreAuthorize("@ss.hasPermi('business:bet:export')")
    @Log(title = "双色球投注", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TDSsqBet tDSsqBet)
    {
        List<TDSsqBet> list = tDSsqBetService.selectTDSsqBetList(tDSsqBet);
        ExcelUtil<TDSsqBet> util = new ExcelUtil<TDSsqBet>(TDSsqBet.class);
        util.exportExcel(response, list, "双色球投注数据");
    }

    /**
     * 获取双色球投注详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:bet:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tDSsqBetService.selectTDSsqBetById(id));
    }

    /**
     * 新增双色球投注
     */
    @PreAuthorize("@ss.hasPermi('business:bet:add')")
    @Log(title = "双色球投注", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDSsqBet tDSsqBet)
    {
        return toAjax(tDSsqBetService.insertTDSsqBet(tDSsqBet));
    }

    /**
     * 修改双色球投注
     */
    @PreAuthorize("@ss.hasPermi('business:bet:edit')")
    @Log(title = "双色球投注", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDSsqBet tDSsqBet)
    {
        return toAjax(tDSsqBetService.updateTDSsqBet(tDSsqBet));
    }

    /**
     * 删除双色球投注
     */
    @PreAuthorize("@ss.hasPermi('business:bet:remove')")
    @Log(title = "双色球投注", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tDSsqBetService.deleteTDSsqBetByIds(ids));
    }
}
